//综合业务查询

import { domainService } from '~/config/server'
import { NetService } from '~/utils/net.service'
import { Inject, Debounce } from "~/core/decorator";
import { FilterService } from '~/utils/filter.service';

export class SynthesizeQueryService {

    @Inject(NetService)
    private netService: NetService

    /**
     * 查询案件流转记录
     */
    public queryCaseTurnRecord(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryCaseTurnRecord,
            data: {
                caseNumber: data.caseNumber,   // 订单编号
                turnSource: data.turnSource,
                turnType: data.turnType,
                lastCollectorName: data.lastCollectorName,
                currentCollectorName: data.currentCollectorName,
                caseTurnTimeMin: FilterService.dateRanageFormat(data.caseTurnTime).start, // 案件流入时间
                caseTurnTimeMax: FilterService.dateRanageFormat(data.caseTurnTime).end,
            },
            page,
            sort
        })
    }

    /**
     * 委外案件查询
     */
    public queryCaseOutRecords(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryCaseOutRecords,
            data: {
                caseNumber: data.caseNumber,
                outBatch: data.outBatch,
                outsourceId: data.outsourceId,
                personalName: data.personalName,
                idCard: data.idCard,
                outTimeMin: FilterService.dateRanageFormat(data.outTime).start,
                outTimeMax: FilterService.dateRanageFormat(data.outTime).end,
                outEndDateMin: FilterService.dateRanageFormat(data.outEndDate).start,
                outEndDateMax: FilterService.dateRanageFormat(data.outEndDate).end,
                caseMoneyMin: data.caseMoney ? data.caseMoney.min : '',
                caseMoneyMax: data.caseMoney ? data.caseMoney.max : '',
            },
            page,
            sort
        })
    }

    /**
     * inBound查询
     */
    public inboundQuery(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.inBoundQuery,
            data: {
                caseNumber: data.caseNumber,
                personalName: data.personalName,
                mobileNo: data.mobileNo,
                idCard: data.idCard,
                area: data.area,
                overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : '',
                overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : '',
                currentCollectorRealName: data.currentCollectorRealName,
                collectionStatus: data.collectionStatus,
                overduePeriod: data.overduePeriod,
                overdueDaysMin: data.overdueDays ? data.overdueDays.min : '',
                overdueDaysMax: data.overdueDays ? data.overdueDays.max : '',
                caseMoneyMin: data.caseMoney ? data.caseMoney.min : '',
                caseMoneyMax: data.caseMoney ? data.caseMoney.max : '',
            },
            page,
            sort
        })
    }

    /**
     * 锁定催收员
     */
    public bindLockingCollector(caseId) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.bindLockingCollector,
            data: {
                caseId
            }

        })
    }

    /**
     * 短信发送查询
     */
    public queryMessageSendRecord(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryMessageSendRecord,
            data: {
                caseNumber: data.caseNumber,
                mobileNo: data.mobileNo,
                messageStatus: data.messageStatus,
                operatorRealName: data.operatorRealName,
                createTimeMin: FilterService.dateRanageFormat(data.createTime).start,
                createTimeMax: FilterService.dateRanageFormat(data.createTime).end,
                batchNumber: data.batchNumber,
                principalId: data.principalId,
                personalName: data.personalName,
                idCard: data.idCard,
                partnerName: data.partnerName,
                bankName: data.bankName,
            },
            page,
            sort
        })
    }

    /**
     * 实时还款查询
     */
    public queryRepaymentRecord(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryRepaymentRecord,
            data: {
                deptCode: data.deptCodes.length === 0 ? "" : data.deptCodes[data.deptCodes.length - 1],
                collectorId: data.collectorId,
                caseMoneyMin: data.caseMoney ? data.caseMoney.min : '',
                caseMoneyMax: data.caseMoney ? data.caseMoney.max : '',
            },
            page,
            sort
        })
    }

    /**
     * 实时还款查询 -> 还款总金额查询
     */
    public getTotalRepayment(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getTotalRepayment,
            data: {
                deptCode: data.deptCodes.length === 0 ? "" : data.deptCodes[data.deptCodes.length - 1],
                collectorId: data.collectorId
            }
        })
    }

    /**
     * 策略分案数据查询列表
     */
    public queryCaseDistributeData(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryCaseDistributeData,
            data: {
                caseNumber: data.caseNumber,
                strategyName: data.strategyName,
                departmentType: data.departmentType,
                distributeDateMin: data.distributeDate.length ? FilterService.dateTimeFormat(data.distributeDate[0]) : '',
                distributeDateMax: data.distributeDate.length ? FilterService.dateTimeFormat(data.distributeDate[1]) : "",
                overdueDaysMin: data.overDueDays ? data.overDueDays.min : '',
                overdueDaysMax: data.overDueDays ? data.overDueDays.max : '',
                overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : "",
                overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : "",
                overduePeriodMin: data.overduePeriodMin ? data.overduePeriodMin : '',
                overduePeriodMax: data.overduePeriodMax ? data.overduePeriodMax : '',
            },
            page,
            sort
        })
    }

    /**
     * 案件查询
     */
    public caseSearch(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.caseSearch,
            data,
            page,
            sort
        })
    }

    /**
     * 
     * 案件查询获取总数的金额
     */
    public caseSearchAmount(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.caseSearchAmount,
            data
        })
    }

    /**
     * 案件导出
     */
    public caseSearchExportCase(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.caseSearchExportCase,
            data
        })
    }

    /**
     * 催记导出
     */
    public caseSearchExportFollow(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.caseSearchExportFollow,
            data
        })
    }
    /**
     * 查询案件状态
     */
    public getCaseCollectionStatus(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getCaseCollectionStatus,
            data: {
                caseType: data
            }
        })
    }
    /**
     * 微信查询记录
     * @param data 
     * @param page 
     */
    public getAllWechatRecord(data, page) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getAllWechatRecord,
            data,
            page
        })
    }
    /**
     * 邮件记录查询
     * @param data 
     * @param page 
     */
    public getAllEmailRecord(data, page) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getAllEmailRecord,
            data,
            page
        })
    }

    /**
     * app 记录查询
     * @param data 
     * @param page 
     */
    public getAllAppRecord(data, page) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getAllAppRecord,
            data,
            page
        })
    }

    /**
     * 剔除案件查询
     */
    public queryEliminateCaseList(data, page?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryEliminateCaseList,
            data,
            page
        })
    }

}
